//
//  Service.m
//  MVC|MVP|MVVM
//
//  Created by Guo Rui on 2017/11/13.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "Service.h"
#import <YYModel.h>
#import "TimelineModel.h"

@implementation Service

static Service *instance;
+ (instancetype)sharedInstance
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[Service alloc] init];
    });
    
    return instance;
}

- (void)fetchTimelineWithCompletion:(void (^)(NSArray *))completiopn
{
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        NSString *path = [[NSBundle mainBundle] pathForResource:@"groupList" ofType:@"plist"];
        NSArray *timelineDicts = [NSArray arrayWithContentsOfFile:path];
        NSArray *timelineModels = [NSArray yy_modelArrayWithClass:[TimelineModel class] json:timelineDicts];
        if (completiopn) {
            completiopn(timelineModels);
        }
    });
}

@end
